package tech.aistar.mapper.wxmapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tech.aistar.entity.daoyou.GuideApply;
import tech.aistar.entity.daoyou.GuideInfo;
import tech.aistar.entity.person_center.Orders;

import java.util.List;

public interface wxGuide {
//获取账单
    @Select("select * from orders where user_id=${value} and order_status=1")
    List<Orders> getBillById(Integer id);

 //通过pohone获取用户id
 @Select("select id from  user_table where phone=${value}")
    Integer getUserId(String  phone);
 //通过用户id去查找
    @Select("select  i.id from  guide_apply a  JOIN guide_info i on (a.id=i.guide_id and a.user_id=${value})")
    Integer getGuideId(Integer id);
//查看用户是否是导游
    @Select("select * from guide_apply where user_id=${value} and apply_status=1")
    GuideApply getGuideById(Integer userId);
    //通过账单id获取
    @Select("select * from orders where id=${value} and order_status=1")
    Orders getOrders(Integer Bill);
    //查看账单核销码
    @Select("select * from orders where id=${value} and order_status")
    Orders selectBill(Integer BillId);
    @Update("update orders set order_status=2,contents_time='${time}' where id=${BillId}")
    void delBill(@Param("BillId") Integer BillId,@Param("time") String time);
    //导游加分
    @Update("update guide_info set reputation =reputation+2 where id=${value}")
    void addGuideScore(Integer id);
    //查看是否被核销

    @Select("select * from orders where id=${value}")
    Orders getBillStart(Integer Bill);

    //    更改订单的评论和星数
    @Update("update  orders  set contents='${text}',contents_type=${contentx_type},contents_time='${time}' where id=${id}")
    void setOrder(@Param("id") Integer id,@Param("time") String time,@Param("text") String text,@Param("contentx_type") Integer contentx_type );

    // 更改分数
    @Update("update guide_info set reputation =(reputation-2+${score}) where id=${id}")
    void updateGuideScore(@Param("id") Integer id,@Param("score") Integer score);


    //更改等级
    @Select("select * from guide_info where id=${value}")
    GuideInfo getd(Integer id);
    @Update("update guide_info set grade=${grade} where id=${id}")
    void updaD(@Param("id") Integer id,@Param("grade") Integer grade);


}
